﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="kam2", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Kam2))]
    public class Kam2Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKam2 clazz;
        
        public Kam2Serializer(IKam2 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("depdate");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Depdate))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("depam");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Depam))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("withddate");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Withddate))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("withdam");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Withdam))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="depdate") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>kam2>depdate");
                }
                clazz.Depdate = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("depdate")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>kam2>depdate", Reader.LocalName);
            }
            if (Reader.LocalName=="depam") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>kam2>depam");
                }
                clazz.Depam = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("depam")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>kam2>depam", Reader.LocalName);
            }
            if (Reader.LocalName=="withddate") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>kam2>withddate");
                }
                clazz.Withddate = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("withddate")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>kam2>withddate", Reader.LocalName);
            }
            if (Reader.LocalName=="withdam") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>kam2>withdam");
                }
                clazz.Withdam = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("withdam")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>kam2>withdam", Reader.LocalName);
            }
        }
    }
}
